from .database import DATABASE_URL, engine
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore


jobstores = {
    'default': SQLAlchemyJobStore(url=DATABASE_URL, engine=engine)
}

executors = {
    'default': ThreadPoolExecutor(10)
}

job_defaults = {
    'coalesce': False,
    'max_instances': 3
}
scheduler = BackgroundScheduler(jobstores=jobstores,
                                job_defaults=job_defaults,
                                executors=executors,
                                timezone='Asia/Shanghai')
